package com.foreknow.demo8;

import com.foreknow.demo2.InterfaceA;

import java.util.Iterator;
import java.util.List;

public class Manager {

    /**
     * 根据id查询某个学生信息
     * @return
     */
    public Student getQueryById(List<Student> list,Integer sid) {
        Student s = null;
        for(int i = 0;i<list.size();i++){
            if (sid.equals(list.get(i).getSid())) {
                s = list.get(i);
                break;
            }
        }
        return s;
    }

    /**
     * 输出学生的信息
     * @param list
     */
    public void getStudentInfo(List<Student> list) {
        //遍历list集合
//                for (Student s:list) {
//                    System.out.println(s.getSid()+"---"+s.getSname());
//                }

//                for(int i = 0;i<list.size();i++) {
//                    Student s = list.get(i);
//                    System.out.println(s.getSid()+"---"+s.getSname());
//                }
//
//                Iterator<Student> it = list.iterator();
//                while (it.hasNext()) {
//                    Student s = it.next();
//                    System.out.println(s.getSid());
//                }
    }
}
